package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Deliver;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class DeliverVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "送货名称")
    private String name;

    @ApiModelProperty(value = "配送人id")
    private Integer deliveryId;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "生产单号id")
    private Integer produceId;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "退货单id")
    private Integer rejectedId;

    @ApiModelProperty(value = "发货状态：0 未发货，1已发货，2，发货完成")
    private Integer deliverStatus;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "收货地址")
    private String address;

    @ApiModelProperty(value = "送货类型")
    private Integer deliverType;

    @ApiModelProperty(value = "司机")
    private String driverName;

    @ApiModelProperty(value = "车牌号")
    private String carNumber;

    @ApiModelProperty(value = "货运单号或者快递单号")
    private String orderNumber;

    @ApiModelProperty(value = "送货状态：0未发货1已发货2已收货")
    private Integer type;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "0生产单 1生产单(重做) 2生产单维修")
    private Integer source;

    @ApiModelProperty(value = "配送时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date deliverTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "确认收货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date deliveryTime;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "生产单名称")
    @TableField(exist = false)
    private String Name;

    @ApiModelProperty(value = "客户名称")
    @TableField(exist = false)
    private String customerName;

    @ApiModelProperty(value = "发货产品详情")
    private List<DeliverProductsVO> deliverProductsVO;

    @ApiModelProperty(value = "附件列表")
    private List<OtherFile> otherFileList;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Deliver convert(DeliverVO vo) {
        Deliver entity = new Deliver();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Deliver> convertList(List<DeliverVO> list) {
        List<Deliver> resultList = new ArrayList<>();
        for (DeliverVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
